<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    img {
      width: 100px;
      height: 100px;
    }

    ul li {
      list-style: none;
    }
  </style>
</head>

<body>
  <ul>
    <li><img src="../img/1.jpg" alt=""></li>
    <li><img src="../img/2.jpg" alt=""></li>
    <li><img src="../img/3.jpg" alt=""></li>
    <li><img src="../img/4.jpg" alt=""></li>
    <li><img src="../img/5.jpg" alt=""></li>
  </ul>
  <script>
    var img = document.getElementsByTagName('img')
    console.log(img)
    for (var i = 0; i < img.length; i++) {
      img[i].onclick = function (e) {
        console.log(e.target)
        document.body.style.backgroundImage = `url(${e.target.src})`
      }
    }
  </script>
</body>

</html>